import axios from 'axios'
export default {
  state: {
    userList: [], //用户所需数据
    token: localStorage.getItem('token'),
  },
  mutations: {
    SET_TOKEN(state, token) {
      state.token = localStorage.token = token
    },
  },
  actions: {
    loginSync({ commit }, { phoneNumber, password }) {
      return axios
        .post('http://sph-h5-api.atguigu.cn/api/user/passport/login', {
          phoneNumber,
          password,
        })
        .then((value) => {
          console.log(value.data)
          commit('SET_TOKEN', value.data.data.token)
        })
    },
  },
  getters: {},
}
